package com.stx;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.CrossOrigin;

@CrossOrigin
@SpringBootApplication(exclude = {ErrorMvcAutoConfiguration.class})
@ServletComponentScan   //识别filter

@MapperScan("com.stx.mapper")
public class App {
    public static void main(String[] args) {
        ConfigurableApplicationContext context =SpringApplication.run(App.class, args);
        // 获取服务器端口
        int port = context.getEnvironment().getProperty("server.port", Integer.class);
        // 获取服务器上下文路径，默认为"/"
        String contextPath = context.getEnvironment().getProperty("server.servlet.context-path", "/");
        if (contextPath.equals("/")) {
            contextPath = "";
        }
        // 输出项目访问地址
        System.out.println("\n访   问  地  址 : http://localhost:" + port + contextPath);

        // 输出 Swagger 文档地址
        System.out.println("\nSwagger 文档地址: http://localhost:" + port + contextPath + "/swagger-ui.html");
        System.out.println("Knife4j 文档地址: http://localhost:" + port + contextPath + "/doc.html");
        System.out.println("\n^_^ 终于……终于跑起来了! HD,不要……不要小看我们的羁绊啊！！！    ORZ···\n\n\n");
    }
}
